package com.xxy.controller;

import com.xxy.result.Result;
import com.xxy.utils.TencentCosUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/upload")
@RequiredArgsConstructor
public class UploadController {

    private final TencentCosUtil cosUtil;

    @PostMapping("/image")
    public Result uploadImage(@RequestParam("file") MultipartFile file) {
        String url = cosUtil.upload(file);
        return Result.success(url);
    }
}
